import 'package:flutter/material.dart';
import '../mainPage/HomePage.dart';
import '../mainPage/ProjectPage.dart';
import '../mainPage/MsgPage.dart';
import '../mainPage/MinePage.dart';

//底部tab切换
class Tabs extends StatefulWidget {
  final index;
  Tabs({Key key, this.index = 0}) : super(key: key);

  @override
  _TabsState createState() => _TabsState(index);
}

class _TabsState extends State<Tabs> {
  int _currentIndex;

  _TabsState(index) {
    this._currentIndex = index;
  }

  List pageList = [
    HomePage(),
    ProjectPage(),
    MsgPage(),
    MinePage(),
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: this.pageList[this._currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: this._currentIndex,
        onTap: (int index) {
          setState(() {});
          this._currentIndex = index;
        },
        iconSize: 25.0,
        type: BottomNavigationBarType.fixed, //超过三个以上需要设置该属性
        fixedColor: Colors.orange,
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.home), label: "首页"),
          BottomNavigationBarItem(icon: Icon(Icons.work), label: "工作台"),
          BottomNavigationBarItem(icon: Icon(Icons.message), label: "消息"),
          BottomNavigationBarItem(icon: Icon(Icons.minimize), label: "我的")
        ],
      ),
    );
  }
}
